package com.PAT.UnSatisfying;


import java.util.*;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2021/12/01/15:39
 * @Description:
 * @Target:差2
 */
public class 图像过滤 {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int M = in.nextInt();
        int N = in.nextInt();
        int A = in.nextInt();
        int B = in.nextInt();
        int val = in.nextInt();

        ArrayList<Integer> list = new ArrayList();
        for (int i = 0; i < M*N; i++) {
                int x = in.nextInt();
                list.add(x);
        }
        Out(M,N,A,B,val,list);


    }


    public static void Out(int M,int N,int A,int B,int val,ArrayList<Integer> list){
        int j = 0;
        for (int x : list) {
            if (x>=A&&x<=B){
                x = val;
                if (j==N-1){
                    System.out.println(setOrGet(x));
                    j=0;
                }else {
                    System.out.print(setOrGet(x)+" ");
                    j++;
                }
            }else {
                if (j==N-1){
                    System.out.println(setOrGet(x));
                    j=0;
                }else {
                    System.out.print(setOrGet(x)+" ");
                    j++;
                }
            }
        }

    }

    // 看x满足要求不,不满足补0
    public static String setOrGet(int x){
        String ss = "";
        if (x<10&&x>0){
            ss = "00"+x;
        }else if (x>=10&&x<100){
            ss = "0"+x;
        }else if (x==0){
            ss = "000";
        }else {
            ss += x;
        }
        return ss;
    }
}
